﻿using System.Collections.Generic;
using Yun.Interface;
using Yun.Open.Response;

namespace Yun.Open.Request
{
    /// <summary>
    /// 获取API列表
    /// yun.open.api.list.get
    /// </summary>
    public class GetApiListRequest: ITopRequest<GetApiListResponse>
    {
        /// <summary>
        /// 页码
        /// </summary>
        public int PageNum
        {
            get { return _pageNum; }
            set
            {
                _pageNum = value < 1 ? 1 : value;
            }
        }

        private int _pageNum = 1;

        /// <summary>
        /// 页容量
        /// </summary>
        public int PageSize
        {
            get { return _pageSize; }
            set
            {
                _pageSize = value < 1 ? 1 : value;
            }
        }

        private int _pageSize = 1;


        /// <summary>
        /// 方法名字，可以进行模糊搜索
        /// </summary>
        public string MethodName { get; set; }

        /// <summary>
        /// 分类ID
        /// </summary>
        public int? CategoryId { get; set; }


        public string GetApiName()
        {
            return "yun.open.api.list.get";
        }

        public IDictionary<string, string> GetParameters()
        {
            var parameters = new YunDictionary
            {
                {"categoryid", CategoryId},
                {"apiid", PageNum},
                {"methodname", MethodName},
                {"pagesize", PageSize}
            };
            return parameters;
        }

        public void Validate()
        {
        }
    }
}
